﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FeedAntGame.Sprite.Event;

namespace FeedAntGame.Control
{
    class Button : BaseControl
    {
        public enum TYPE { MENU, NEW_GAME, QUIT, GO, OK, RESUME, RESUME2, OPTION, HIGH_SCORES, MAIN_MENU, PLAY_AGAIN}
        TYPE type;

        
        /************************************************************************/
        /*                  GET/SET                                                                     */
        /************************************************************************/
        internal TYPE Type
        {
            get { return type; }
            set 
            { 
                type = value;
                createInstance(sprite.Position);
            }
        }

        
        /************************************************************************/
        /*                  Constructor                                                                     */
        /************************************************************************/
        public Button(Game game, TYPE type, Vector2 position)
            :base(game)
        {
            this.game = game;
            this.type = type;
            createInstance(position);
        }

        protected override void createInstance(Vector2 position)
        {
            switch (type)
            {
                case TYPE.QUIT:
                    sprite = new EventSprite(
                        Game.Content.Load<Texture2D>(@"Images\quit_cover"),
                        Game.Content.Load<Texture2D>(@"Images\quit_normal"),
                        Game.Content.Load<Texture2D>(@"Images\quit_cover"), null,position,
                        new Point(52, 27), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.NEW_GAME:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\new_game_cover"),
                       Game.Content.Load<Texture2D>(@"Images\new_game_normal"),
                       Game.Content.Load<Texture2D>(@"Images\new_game_cover"), null, position,
                       new Point(128, 50), 10, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.MENU:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\menu_button_cover"),
                       Game.Content.Load<Texture2D>(@"Images\menu_button_normal"),
                       Game.Content.Load<Texture2D>(@"Images\menu_button_cover"), null, position,
                       new Point(104, 30), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.OK:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\OK_cover"),
                       Game.Content.Load<Texture2D>(@"Images\OK_normal"),
                       Game.Content.Load<Texture2D>(@"Images\OK_cover"), null, position,
                       new Point(167, 53), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.GO:
                    sprite = new EventSprite(
                        Game.Content.Load<Texture2D>(@"Images\go_button_cover"),
                        Game.Content.Load<Texture2D>(@"Images\go_button_normal"),
                        Game.Content.Load<Texture2D>(@"Images\go_button_cover"),
                        Game.Content.Load<Texture2D>(@"Images\go_button_disable"),
                        position, new Point(88, 48), 5, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.RESUME:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\resume_button_hover"),
                       Game.Content.Load<Texture2D>(@"Images\resume_button_normal"),
                       Game.Content.Load<Texture2D>(@"Images\resume_button_hover"),
                       Game.Content.Load<Texture2D>(@"Images\resume_button_hover"), position,
                       new Point(140, 32), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.RESUME2:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\resume_cover"),
                       Game.Content.Load<Texture2D>(@"Images\resume_normal"),
                       Game.Content.Load<Texture2D>(@"Images\resume_cover"),
                       Game.Content.Load<Texture2D>(@"Images\resume_normal"), position,
                       new Point(81, 18), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.OPTION:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\option_cover"),
                       Game.Content.Load<Texture2D>(@"Images\option_normal"),
                       Game.Content.Load<Texture2D>(@"Images\option_cover"), null, position,
                       new Point(78, 27), 5, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);                    
                    break;
                case TYPE.HIGH_SCORES:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\high_scores_cover"),
                       Game.Content.Load<Texture2D>(@"Images\high_scores_normal"),
                       Game.Content.Load<Texture2D>(@"Images\high_scores_cover"), null, position,
                       new Point(107, 24), 5, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);    
                    break;
                case TYPE.MAIN_MENU:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\main_menu_cover"),
                       Game.Content.Load<Texture2D>(@"Images\main_menu_normal"),
                       Game.Content.Load<Texture2D>(@"Images\main_menu_cover"), null, position,
                       new Point(90, 14), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);
                    break;
                case TYPE.PLAY_AGAIN:
                    sprite = new EventSprite(
                       Game.Content.Load<Texture2D>(@"Images\play_again_cover"),
                       Game.Content.Load<Texture2D>(@"Images\play_again_normal"),
                       Game.Content.Load<Texture2D>(@"Images\play_again_cover"), null, position,
                       new Point(61, 14), 0, new Point(1, 1), Vector2.Zero, "buttoncollision", 1);                    
                    break;
                    
            }
        }
    }
}
